/**
 * Created by lixiaodi on 2019/03/15.
 */
mini.parse();
var grid = mini.get('datagrid1');
//初始化
$(function(){
	$.ajax({
		url: ajaxUrl + "/menus/queryListPar.do",
        type: 'POST',
        contentType : "application/json",
        success: function (data) {
        	var menusObj = data.menus;
        	grid.setData(menusObj);
        },
        error: function (jqXHR, textStatus, errorThrown) {
            //alert(jqXHR.responseText);
            //CloseWindow();
        	console.log('请求失败');
        }
	})
});
//保存
function SaveData(){
	var selectMenus = grid.getSelected();
	if(selectMenus){
		console.log(selectMenus);
		CloseWindow('ok')
	}else{
		mini.alert('请选择父级菜单');
	}
}
function GetData(){
	var selectMenus = grid.getSelected();
	return selectMenus;
}
//关闭子页面
function CloseWindow(action) {
    if (action == "close" && form.isChanged()) {
        if (confirm("数据被修改了，是否先保存？")) {
            return false;
        }
    }
    if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
    else window.close();
}
function onOk(e) {
    SaveData();
}
function onCancel(e) {
    CloseWindow("cancel");
}